class StudCardDetail {
    constructor(id, tableId) {

        this.id = id;

        this.tableId = tableId;

        this.sid = '';
  


        this.tableSetup = {
            elem: "#" + this.tableId
            , defaultToolbar: ['filter', 'print', 'exports']
            // , height: 312
            , url: '/Lock/GetStudEle' //数据接口
            , where: { idCard: this.idCard }
            , page: true //开启分页
            , toolbar: true
            , cols: [[ //表头
                { field: 'cid', title: '课程', width: '20%', sort: true }
                , { field: 'cname', title: '课程名', width: '20%' }
                , { field: 'tname', title: '任教教师', width: '20%', sort: true }
                , { field: 'cscore', title: '分数', width: '20%', sort: true }
                , {
                    field: 'isPass', title: '是否及格',
                    templet: function (d) {
                        if (d.cscore) {
                            if (d.cscore >= 60) return "及格";
                            else return "不及格";
                        } else {
                            return "";
                        }
                    }
                    , width: '20%', sort: true
                }
            ]]
            , contentType: 'jsonp'//一定要是jsonp类型
            , parseData: function (res) { //res 即为原始返回的数据
                console.log("parseDate");
                // console.log(res.status)
                console.log(res);
                var arry = [];
                var list = res.list;
                for (let i = 0; i < list.length; i++) {
                    let e = list[i];
                    arry[i] = ({
                        'cid': e.cid
                        , 'cname': e.course.cname
                        , 'tname': e.course.teacher.tname
                        , 'cscore': e.cscore
                    });
                }
                console.log(arry);

                return {
                    "code": res.statue, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": arry.length, //解析数据长度
                    "data": arry //解析数据列表
                };
            }
            , request: {
                pageName: 'pageInd' //页码的参数名称，默认：page
                , limitName: 'rowCount' //每页数据量的参数名，默认：limit
            }
            , done: function (resp) {

                // if()

            }
        }

    }
    start(ind) {

        console.log("ind=" + ind);
        let load = this;
        if (ind) {
            load.sid = ind;
        }
        $("#" + load.id).show().siblings().hide();
        load.render(load.sid);
    }

    render(ind) {
        // 教师号
        let load = this;
        let aid = this.tid;

        load.renderStudDetailsTable(ind);

    }





    // 渲染教师详情页的折叠面板项
    renderStudDetailsTable(sid) {

        let load = this;

        console.log("renderStudDetailsTable--sid");
        console.log(sid);

        load.tableSetup.where['sid'] = sid;

        console.log(load.tableSetup);

        layui.table.render(load.tableSetup);


    }

}